﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Employees_EmployeesContactList : System.Web.UI.Page
{
    private Srvtools.WebDataSet WMaster;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            InitializeComponent(false);

            Master.DataSource = WMaster;

            wgvMaster.Visible = false;

            ddlStatus.SelectedValue = "1";
        }
    }

    private void InitializeComponent(bool action)
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Employees_EmployeesContactList));
        this.WMaster = new Srvtools.WebDataSet();
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).BeginInit();
        // 
        // WMaster
        // 
        this.WMaster.Active = action;
        this.WMaster.AlwaysClose = false;
        this.WMaster.PacketRecords = 100;
        this.WMaster.Position = -1;
        this.WMaster.RemoteName = "SEmployees.ViewEmpContacts";
        this.WMaster.ServerModify = false;
        ((System.ComponentModel.ISupportInitialize)(this.WMaster)).EndInit();

    }

    protected void Search_Click(object sender, EventArgs e)
    {
        //Search.CssClass = "OnHover";

        string strDep = Depart.SelectDepmanetId;
        if (strDep == "")
        {
            return;
        }
        else if (strDep == "0")
        {
            strDep = "";
        }
        else
        {
            strDep = "And DepartmentId like ('" + strDep + "%')";
        }


        string sname = SelUser.EmpName;
        if (sname != "")
        {
            sname = "And EmpName like ('%" + sname + "%')";
        }
        else
        {
            sname = "";
        }

        string Status = ddlStatus.SelectedValue;
        if (Status == "-1")
        {
            Status = "";
        }
        else
        {
            Status = " And EmpStatus = " + Status;
        }

        InitializeComponent(true);

        WMaster.SetWhere("1=1 " + strDep + sname + Status);


        Master.DataSource = WMaster;

        wgvMaster.Visible = true;
       
    }



    protected void wgvMaster_DataBound(object sender, EventArgs e)
    { 
        
        MasterPage_MasterPage master = (MasterPage_MasterPage)this.Page.Master;
    
        master.PicUrl = "~/image/PageIcon/tongxunlu.jpg";
        if (Request["ItemParam"].ToString() == "edit")
        {
            wgvMaster.Columns[0].Visible = true;

      
           
            master.HelpHref = "";
            master.PageName = "员工通讯录（编辑）";
            
            
        }
        else
        {
         
            master.HelpHref = "";
            master.PageName = "员工通讯录（查看）";
           

            wgvMaster.Columns[0].Visible = false;
            ddlStatus.SelectedValue = "1";
            ddlStatus.Enabled = false;  
        }
        master.IntiBar();
    }
}
